import json

print("\n##########################prac-10.1#########################")
with open('learning_python.txt') as f:
    print(f.read())

print('**********************read 1***********************')
with open('learning_python.txt') as f:
    lines = f.readlines()
    for line in lines:
        print(line.rstrip())

print('**********************read 2***********************')
with open('learning_python.txt') as f:
    lines = f.readlines()
    for line in lines:
        print(line.rstrip())

print('**********************read 3***********************')
for line in lines:
    print(line.rstrip())

message = 'i really like dogs'
message = message.replace('dogs','cats')
print(message)

with open('learning_python.txt') as f:
    lines = f.readlines()
    for line in lines:
        print(line.replace('Python',"C").rstrip())

print("\n##########################10.2#########################")
file_name = 'programming.txt'
with open(file_name,'a') as f:
    f.write('i love programming.\n')
    f.write('i love programming23.\n')

print("\n##########################prac-10.2#########################")
# name = input('input your name:')
# with open('guest.txt','w') as f:
#     f.write(name)
#
#
# while True:
#     name = input('input your name:')
#     with open('guest_book.txt','a') as f:
#         print ('hello ' + name)
#         f.write(name.rstrip() + '\n')
#
#     flag = input('continue(y/n):')
#     if flag == 'n':
#         break
#
# while True:
#     name = input('why do you like programming?:')
#     with open('programming_reason.txt','a') as f:
#         f.write(name.rstrip() + '\n')
#
#     flag = input('continue(y/n):')
#     if flag == 'n':
#         break

print("\n##########################10.3#########################")
try:
    num = 10 / 0
    print(num)
except:
    print('hehe,u idiot')

title = 'Alice     In Wonderland'
print(title.split())

try:
    with open('alice-in-wonderland1.txt') as f:
        s = f.read()
except:
    pass
else:
    arr = s.split()
    print('alice in wonderland has ' + str(len(arr)) + ' words')

print("\n##########################10.3-prac#########################")
num1 = 10
num2 = 2
try:
    r = num1 / num2
    print(int(r))
except TypeError:
    print('some number is not numer')


print("\n##########################10.4#########################")
numbers = [1,3,5,7,9]
# with open('jsonfile.txt','w') as f:
#     json.dump(numbers,f)

with open('jsonfile.txt') as f:
    nunbers2 = json.load(f)

print(nunbers2)